﻿using Dapper;
using System;
using BCEntity.Website.UserAddress;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading.Tasks;

namespace BCData.Website.UserAddress
{
    /// <summary>
    /// 用户地址
    /// </summary>
    public interface IUserAddressData
    {
        #region  成员方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="userAddressId">用户地址Id</param>
        Task<bool> Exists(long userAddressId);
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="userId">用户Id</param>
        Task<bool> ExistsByUserId(long userId);
        /// <summary>
        /// 增加用户地址
        /// </summary>
        /// <param name="entity">用户地址信息</param>n 
        Task<UserAddressEntity> Add(UserAddressEntity entity);
        /// <summary>
        /// 更新用户地址
        /// </summary>
        /// <param name="entity">用户地址信息</param>
        Task<UserAddressEntity> Update(UserAddressEntity entity);
        /// <summary>
        /// 取消默认地址
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <returns></returns>
        Task<bool> CancelIsDefault(long userId);
        /// <summary>
        /// 设置默认地址
        /// </summary>
        /// <param name="userAddressId">用户地址Id</param>
        /// <returns></returns>
        Task<bool> SettingIsDefault(long userAddressId);
        /// <summary>
        /// 删除用户地址
        /// </summary>
        /// <param name="userAddressId">用户地址Id</param>
        Task<bool> Delete(long userAddressId);
        /// <summary>
        /// 获取用户地址
        /// </summary>
        /// <param name="userAddressId">用户地址Id</param>
        Task<UserAddressEntity> GetEntity(long userAddressId);
        /// <summary>
        /// 获取用户地址列表
        /// </summary>
        /// <param name="userId">用户Id</param>
        Task<IEnumerable<UserAddressEntity>> GetList(long userId);
        /// <summary>
        /// 获取用户地址总数
        /// </summary>
        /// <param name="userId">用户Id</param>
        Task<int> Count(long userId);
        /// <summary>
        /// 获取用户地址分页列表
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="sortName">排序字段</param>
        /// <param name="ascending">升序</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        Task<(IEnumerable<UserAddressEntity>, int)> Query(long? userId, DateTime? start, DateTime? end, string sortName, bool? ascending, int pageIndex, int pageSize);
        #endregion  成员方法
    }


}